package com.sjq.servlet;

import com.sjq.bean.User;
import org.apache.tomcat.jni.Error;
import org.apache.tomcat.util.descriptor.web.ErrorPage;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet(name = "loginSeverlet",urlPatterns = {"/login.html"})
public class LoginServlet extends BaseServlet {
    public void doGet(HttpServletRequest request,HttpServletRequest response)throws ServletException, IOException{
        this.doPOST(request,response);
    }
    public void doPOST(HttpServletRequest request,HttpServletRequest response)throws ServletException, IOException{
        try{
            String userid=request.getParameter("userid");
            String pwd=request.getParameter("pwd");
            User user=new User();
            boolean flag= user.check(userid,pwd);
            if(flag){
                super.dispathcher(request, (HttpServletResponse) response,"/index.jsp");
            }else{
                super.dispathcher(request, (HttpServletResponse) response,"/index.jsp");
            }
        }catch (Exception e){
            e.printStackTrace();
            /**super.redirect(request,response,);**/
        }
    }
}
